package com.longchat.domain.award;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="vote_log")
public class VoteLog {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@Column(name="openid")
	private String openid;
	@ManyToOne
	@JoinColumn(name="question_id")
	private Questionnaire questionnarire;
	@ManyToMany(cascade=CascadeType.ALL)
	@JoinTable(name = "vote_option",
			joinColumns = {@JoinColumn(name = "votelog_id", referencedColumnName = "id")},
			inverseJoinColumns = {@JoinColumn(name = "option_id", referencedColumnName ="id")})
	private List<Option> options = new ArrayList<>();
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public Questionnaire getQuestionnarire() {
		return questionnarire;
	}
	public void setQuestionnarire(Questionnaire questionnarire) {
		this.questionnarire = questionnarire;
	}
	public List<Option> getOptions() {
		return options;
	}
	public void setOptions(List<Option> options) {
		this.options = options;
	}
	
}
